package org.shijiagen.manager.controller;

import lombok.RequiredArgsConstructor;
import org.shijiagen.manager.service.CategoryService;
import org.shijiagen.param.PageParam;
import org.shijiagen.pojo.Category;
import org.shijiagen.utils.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("category")
@RequiredArgsConstructor
public class CategoryController {

    private final CategoryService categoryService;

    @GetMapping("list")
    public R pageList(PageParam param){
        return categoryService.pageList(param);
    }

    @PostMapping("save")
    public R save(Category category){
        return categoryService.save(category);
    }

    @PostMapping("remove")
    public R remove(Integer categoryId){
        return categoryService.remove(categoryId);
    }

    @PostMapping("update")
    public R update(Category category){
        return categoryService.update(category);
    }
}
